{if $user_loggedIn}
[ <a href="index.php?p=edit&ID={$entryID}">Edit</a> ]
{/if}
{if $user_admin}
[ <a style="color: #f00;" href="index.php?p=delete&ID={$entryID}" class="adminreq" onclick="return confirm('Are you sure you want to permanently delete this entry along with any PDF documents and history associated with it?');">Delete</a> ]
{/if}
{if $user_loggedIn}
<div id="projects" style="display: none;">
<form method="post" action="index.php">
<select name="add_to_project">
{foreach from=$projects item=p}
<option value="p{$p.ID}f0">{$p.name}</option>
    {foreach from=$p.folders item=f}
    <option value="p{$p.ID}f{$f.ID}">-- {$f.name}</option>
    {/foreach}
{/foreach}
</select>
<input type="hidden" name="p" value="projects" />
<input type="hidden" name="entryID" value="{$entryID}" />
<input type="submit" value="Add To Project" />
</form>
<h1 style="font-size: small;">Projects Already In</h1>
{foreach from=$projects item=p}
    {if $p.inproject == true}<a style="font-size: small;" href="index.php?p=projects&amp;projectID={$p.ID}">{$p.name}</a><br />{/if}
    {foreach from=$p.folders item=f}
    {if $f.inproject == true}<a style="font-size: small;" href="index.php?p=projects&amp;projectID={$p.ID}&amp;folderID={$f.ID}">{$p.name} :: {$f.name}</a><br />{/if}
    {/foreach}
{/foreach}
</div>
{/if}
<div id="view">

  <table>

{if $user_loggedIn}
<tr>
    <th colspan="3" class="section">Metadata and Projects</th>
</tr>
<tr><th colspan="3" style="padding: 0; text-align: center;" align="center">
    {literal}
    <script>
    $( function() { $('a[rel*=facebox]').facebox(); } );
    </script>
    {/literal}
    <a href="#projects" rel="facebox">Manage Projects</a>
    <button id="editmetadata">Edit Metadata</button>
    <form method="post" action="index.php" style="margin: 0; padding: 0;">  
    {include file="metadata.tpl"}
    <input type="hidden" name="ID" value="{$entryID}" />
    <input type="hidden" name="p" value="{$page}" />
    </form>
</th></tr>

{foreach from=$metadata key=k item=v}
    {if trim($v) != ''}    
        <tr>
            <th>{$k|capitalize}</th>
            <td colspan="2">{$v}</td>
        </tr>
    {/if}
{/foreach}

    {if sizeof($warnings) > 0}
        <tr>
            <th colspan="3" class="section">Warnings</th>
        </tr>

        {if !$suppressWarnings}
            <tr>
                <td colspan="3" style="background-color: #FDD; text-align: center; font-size: smaller;">
                   [ <a href="index.php?p={$page}&amp;ID={$entryID}&amp;suppressWarnings=1" style="color: #800;">Suppress Warnings</a> ]
                </td>
            </tr>
            {foreach from=$warnings key=k item=v}
                <tr>
                    <th colspan="3" class="section" style="background-color: #F88; color: #800;">
                       {$v} 
                    </th>
                </tr>
            {/foreach}
        {else}
            <tr>
                <td colspan="3" style="background-color: #FDD; text-align: center; font-size: smaller;">
                   [ <a href="index.php?p={$page}&amp;ID={$entryID}&amp;suppressWarnings=0" style="color: #800;">Unsuppress Warnings ({$warnings|@sizeof})</a> ]
                </td>
            </tr>
        {/if}
    {/if}

{/if}
  
    <tr>
        <th colspan="3" class="section">{$entrytype|capitalize}</th>
    </tr>
    {assign var="rowCount" value = 0}
    {foreach from=$entry key=k item=v}
        {if trim($v) != '' && $k != 'abstract'}    
            {assign var="rowCount" value=$rowCount+1}
        {/if}
    {/foreach}
    {foreach from=$entry key=k item=v}
        {if trim($v) != '' && $k != 'abstract'}    
            <tr>
                <th>{$k|capitalize}</th>
                <td width="100%">{$v}</td>

                {if $k == 'Entry Key' && isset($filename) && $user_loggedIn}
                    <td rowspan="{$rowCount+1}" valign="center" align="center" style="padding: 0;">
                    {if isset($preview)} <a href="uploads/{$filename}"><img style="border: 1px solid #000;" title="PDF Preview" src="uploads/{$preview[0]}" longdesc="uploads/{$preview[1]}" /></a>{/if}
                    <a href="uploads/{$filename}" class="filedownload">Download</a>
                </td>
                {/if}
            </tr>
        {/if}
    {/foreach}

    <tr>
        <th>External&nbsp;Links</th>
        <td><a href="http://scholar.google.com/scholar?hl=en&amp;q=allintitle%3A+{urlencode val=$entry.title}" target="_new">Google Scholar</a></td>
    </tr>
    
    {if $entry.abstract}
        <tr>
            <th colspan="3" class="section">Abstract</th>
        </tr>        
        <tr>
            <td colspan="3" class="abstract">{$entry.abstract}</td>
        </tr>
    {/if}
    
    
  </table>
</div> 

<h2>History <button id="historytrigger">Show/Hide</button></h2>
<div id="history">
{foreach from=$history item=v}
<span>{$v.time}</span><p>{$v.desc}</p>
{/foreach}
</div>


{literal}
<script type="text/javascript"> 
  $("#historytrigger").click(function () {
    $("#history").slideToggle("normal");
  }); 
  
  $(function() {
    $('#metadatabox').hide();
    $('#editmetadata').click(function () { $('#metadatabox').slideToggle("normal") } );
  });
</script>
{/literal}
